package util;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Table {

	private Map<Integer, Storage<String>> map;

	public Table(int size) {
		this.map = new HashMap<Integer, Storage<String>>();
		fillMap(size);
	}

	private void fillMap(int sizeTable) {
		for (int i = 0; i < sizeTable; i++) {
			Storage<String> storageValue = new Storage<String>(
					String.valueOf(i));
			map.put(i, storageValue);
		}
	}

	public Map<Integer, Storage<String>> getMap() {
		return map;
	}

	public void setMap(Map<Integer, Storage<String>> tabela) {
		this.map = tabela;
	}

	public Storage<String> readValue(int key) {
		return map.get(key);
	}

	public synchronized Set<Integer> getKeySet() {
		return map.keySet();
	}

	public synchronized Storage<String> putValue(int key, String value) {
		Storage<String> stor = new Storage<String>(value);
		return map.put(key, stor);
	}

	public int size() {
		return map.size();
	}

}
